<?php

namespace App\Console\Commands\Init;

use App\Models\Role;
use App\Models\Permission;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class PermissionsCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'init:permissions';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '初始化系统权限列表以及超级管理员';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        DB::beginTransaction();
        try{
            Role::create(['name'=>'TestManagerG','cn_name'=>'测试管理员G']);
            Permission::create();
            DB::commit();
        }catch (\Exception $exception){
            DB::rollBack();
        }

    }
}
